{include file="public/nheader"}
<style type="text/css">
    .uploader-list {

        margin-left: -15px;

    }

    .uploader-list .info {

        position: relative;

        margin-top: -25px;

        background-color: black;

        color: white;

        filter: alpha(Opacity=80);

        -moz-opacity: 0.5;

        opacity: 0.5;

        width: 100px;

        height: 25px;

        text-align: center;

        display: none;

    }



    .uploader-list .handle {

        position: relative;

        background-color: black;

        color: white;

        filter: alpha(Opacity=80);

        -moz-opacity: 0.5;

        opacity: 0.5;

        width: 100px;

        text-align: right;

        height: 18px;

        margin-bottom: -18px;

        display: none;

    }



    .uploader-list .handle i {

        margin-right: 5px;

    }



    .uploader-list .handle i:hover {

        cursor: pointer;

    }



    .uploader-list .file-iteme {

        margin: 12px 0 0 15px;

        padding: 1px;

        float: left;

    }
</style>
<div class="layui-fluid layui-bg-white">
    <form action="{:url()}" class="layui-form layui-form-fixed">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>产品名称
            </label>
            <div class="layui-input-block">
                <input type="text" id="title" name="title" required="" lay-verify="required" autocomplete="off"
                    class="layui-input" value="{$row.title|default=''}" placeholder="请输入商品名称">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>产品短标题
            </label>
            <div class="layui-input-block">
                <input type="text" id="shortitle" name="shortitle" required="" lay-verify="required" autocomplete="off"
                    class="layui-input" value="{$row.shortitle|default=''}" placeholder="请输入商品短标题">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>分类
            </label>
            <div class="layui-input-block">
                <select name="cateid" lay-verify="required">
                    {foreach $class as $v}
                    <option value="{$v.id}" {if !empty($row.cateid) && $row.cateid==$v.id}selected{/if}>
                        {$v.name}
                    </option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>库存
            </label>
            <div class="layui-input-block">
                <input type="number" id="sku" name="sku" required="" lay-verify="required" autocomplete="off"
                    class="layui-input" value="{$row.sku|default=''}" placeholder="请输入库存">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>销量
            </label>
            <div class="layui-input-block">
                <input type="number" id="sales" name="sales" required="" lay-verify="required" autocomplete="off"
                    class="layui-input" value="{$row.sales|default='0'}" placeholder="请输入销量">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>需要积分
            </label>
            <div class="layui-input-block">
                <input type="number" id="intergral" name="intergral" required="" lay-verify="required"
                    autocomplete="off" class="layui-input" value="{$row.intergral|default=''}" placeholder="请输入积分">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>需要价格
            </label>
            <div class="layui-input-block">
                <input type="number" id="price" name="price" required="" lay-verify="required" autocomplete="off"
                    class="layui-input" value="{$row.price|default=''}" placeholder="请输入价格">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>产品图
            </label>
            <div class="layui-input-block">
                <button type="button" class="layui-btn" id="test2">图片上传</button>
                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 95%">
                    预览图：
                    <div class="layui-upload-list uploader-list" style="overflow: auto;" id="uploader-list">
                        {if !empty($row.images)}
                        {foreach $row.images as $v}
                        <div class="file-iteme">
                            <div class="handle" style="display: none;">
                                <i class="layui-icon layui-icon-delete"></i>
                            </div><img style="width: 100px;height: 100px;" src="{$v}">
                            <input type="hidden" name="images[]" value="{$v}">
                        </div>
                        {/foreach}
                        {/if}
                    </div>
                </blockquote>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>产品详情图
            </label>
            <div class="layui-input-block">
                <button type="button" class="layui-btn" id="test3">图片上传</button>
                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 95%">
                    预览图：
                    <div class="layui-upload-list uploader-list" style="overflow: auto;" id="uploader-list1">
                        {if !empty($row.detail)}
                        {foreach $row.detail as $v}
                        <div class="file-iteme">
                            <div class="handle" style="display: none;">
                                <i class="layui-icon layui-icon-delete"></i>
                            </div><img style="width: 100px;height: 100px;" src="{$v}">
                            <input type="hidden" name="detail[]" value="{$v}">
                        </div>
                        {/foreach}
                        {/if}
                    </div>
                </blockquote>
            </div>
        </div>
        <div class="layui-footer layui-form-item layui-center ">
            <input type="hidden" value="{$row['id']|default='0'}" name="id" />
            <button class="layui-btn" lay-filter="submitIframe" type="button" lay-submit>提交</button>
            <button class="layui-btn layui-btn-primary" type="button" sa-event="closeDialog">取消</button>
        </div>
    </form>
</div>
{include file="public/nfooter"}
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>

<script>
    // 删除图片
    $(document).on("click", ".file-iteme .handle", function (event) {
        $(this).parent().remove();
    });
    $(document).on("mouseenter mouseleave", ".file-iteme", function (event) {
        if (event.type === "mouseenter") {
            //鼠标悬浮
            $(this).children(".info").fadeIn("fast");
            $(this).children(".handle").fadeIn("fast");
        } else if (event.type === "mouseleave") {
            //鼠标离开
            $(this).children(".info").hide();
            $(this).children(".handle").hide();
        }
    });
    layui.use('upload', function () {
        var $ = layui.jquery
            , upload = layui.upload;
        var demoListView = $('#demoList'),
            uploadListIns = upload.render({
                elem: '#test2'
                , url: '/base/upload_img'
                , multiple: true
                , before: function (obj) {
                    layer.load(); //上传loading
                }
                , done: function (res) {
                    if (res.code == 200) {
                        //上传完毕
                        $('#uploader-list').append(
                            '<div id="" class="file-iteme">' +
                            '<div class="handle"><i class="layui-icon layui-icon-delete"></i></div>' +
                            '<img style="width: 100px;height: 100px;" src=' + res.url + '>' +
                            '<input type="hidden" name="images[]" value="' + res.url + '"></div>'
                        );
                    }
                    layer.closeAll('loading'); //关闭loading
                    return layer.msg(res.msg);
                }
                , error: function () {
                    layer.closeAll('loading'); //关闭loading
                    return layer.msg(res.msg);
                }
            });
        uploadListIns = upload.render({
            elem: '#test3'
            , url: '/base/upload_img'
            , multiple: true
            , before: function (obj) {
                layer.load(); //上传loading
            }
            , done: function (res) {
                if (res.code == 200) {
                    //上传完毕
                    $('#uploader-list1').append(
                        '<div id="" class="file-iteme">' +
                        '<div class="handle"><i class="layui-icon layui-icon-delete"></i></div>' +
                        '<img style="width: 100px;height: 100px;" src=' + res.url + '>' +
                        '<input type="hidden" name="detail[]" value="' + res.url + '"></div>'
                    );
                }
                layer.closeAll('loading'); //关闭loading
                return layer.msg(res.msg);
            }
            , error: function () {
                layer.closeAll('loading'); //关闭loading
                return layer.msg(res.msg);
            }
        });
    });

</script>